{extend name="../public/header" /}
{block name="body"}
<body>
{include file="../public/top" uname="$roleInfo.uname" lv="$roleInfo.ulv" ls="$roleInfo.uyxb" jp="$roleInfo.uczb" /}
<div class="subject main">
    <div class="layui-row">
        <div class="content">
            <div class="current">
                <span class="position">{$roleInfo.map.mname}</span>
                <span class="state">{if $roleInfo.map.ispvp==0}[安全区]{else/}[PVP]{/if}</span>
                <span class="info ajax-goto" data-url="{:url('home/index')}">返回</span>
            </div>
            <div class="npc">
                <div class="layui-panel">
                    <div style="padding:10px;">
                        <span class="layui-breadcrumb" lay-separator="|">
                            <a class="ajax-goto" data-url="{:url('package/myEquip')}">装备</a>
                            <a class="ajax-goto" data-url="{:url('package/myProp')}">道具</a>
                            <a class="ajax-goto" data-url="{:url('package/myDrug')}">丹药</a>
                            <a class="ajax-goto" data-url="{:url('package/myTask')}">任务</a>
                        </span>
                        <table class="layui-table" style="width:100%;text-align:center;">
                            <colgroup>
                                <col width="30%">
                                <col width="40%">
                                <col width="30%">
                            </colgroup>
                            <tbody>
                            <tr>
                                <td class="ajax-equip" data-value="{$info.tool2}" data-type="1">{$info.tool2Name}</td>
                                <td rowspan="3"><img src='{$info.usexImg}' style="width: 120px;max-width:none;"></td>
                                <td class="ajax-equip" data-value="{$info.tool5}" data-type="1">{$info.tool5Name}</td>
                            </tr>
                            <tr>
                                <td class="ajax-equip" data-value="{$info.tool3}" data-type="1">{$info.tool3Name}</td>
                                <td class="ajax-equip" data-value="{$info.tool4}" data-type="1">{$info.tool4Name}</td>
                            </tr>
                            <tr>
                                <td class="ajax-equip" data-value="{$info.tool1}" data-type="1">{$info.tool1Name}</td>
                                <td class="ajax-equip" data-value="{$info.tool6}" data-type="1">{$info.tool6Name}</td>
                            </tr>
                            </tbody>
                        </table>
                        <div class="layui-row layui-col-space10 shop" style="border: #D5CBCB 1px solid;">
                            {volist name="listMyEquip" id="vo"}
                            <div class="layui-col-xs4">
                                <div class="grid-demo">
                                    <div class="shop-img ajax-equip" data-value="{$vo.zbnowid}" data-type="2"><img src='{$vo.thumb}' style="width:64px;max-width:none;"></div>
                                    <div class="shop-title">{$vo.zbname}</div>
                                    <div class="shop-lable">
                                        <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-act" data-act="wear" data-id="{$vo.zbnowid}">穿</a>
                                        <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-sell" data-act="sell" data-id="{$vo.zbnowid}">售</a>
                                        <a class="layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-act" data-act="lose" data-id="{$vo.zbnowid}">丢</a>
                                    </div>
                                </div>
                            </div>
                            {/volist}
                            {for start="1" end="$surplusLattice"}
                            <div class="layui-col-xs4">
                                <div class="grid-demo" style="height:124px;line-height:124px;background-color: #EFEFEF;">空</div>
                            </div>
                            {/for}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{/block}
{block name="script"}
<script>
    layui.use(['jquery', 'form', 'layajax', 'upload', 'flow', 'element'], function () {
        var $ = layui.jquery
            , layajax = layui.layajax
            , upload = layui.upload
            , element = layui.element
            , flow = layui.flow
            , form = layui.form;

        $('.ajax-equip').on('click', function () {
            var value = $(this).data('value');
            var type = $(this).data('type');

            var map = {};
            map['id'] = value;

            $.post('{:url("getRoleEquip")}', map, function (res) {
                console.log('res', res);

                if (res.code == undefined) {
                    console.log('res为json字符串', res);
                    res = JSON.parse(res);
                } else {
                    console.log('res为json对象', res);
                }
                if (res.code == 1) {
                    var ary = res.data;
                    var htmlCtn = '';

                    if(type == 1){
                        htmlCtn = "<p><span style='color: #C2C2C2;'>穿戴等级:" + ary.zblv + "</span> <a class='layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-remove' data-act='remove' data-id='" + ary.zbnowid + "'>卸下</a></p>";
                    }else{
                        htmlCtn = "<p><span style='color: #C2C2C2;'>穿戴等级:" + ary.zblv + "</span>";
                    }

                    var content = "<p><h3 style='color: #1E9FFF;font-weight: 600;'>" + ary.zbname + "</h3></p>" + htmlCtn +
                        "<p><span style='color: #31BDEC;'>强化: +" + ary.qianghua + "</span> <a class='layui-btn layui-btn-xs layui-btn-primary layui-border-blue ajax-strong' data-id='" + ary.zbnowid + "'>强化</a></p>" +
                        "<p><hr></p>" +
                        "<p><span style='color: #FFB800;'>生命: +" + ary.zbhp + "</span></p>" +
                        "<p><span style='color: #FFB800;'>攻击: +" + ary.zbgj + "</span></p>" +
                        "<p><span style='color: #FFB800;'>防御: +" + ary.zbfy + "</span></p>" +
                        "<p><span style='color: #FFB800;'>暴击: +" + ary.zbbj + "</span></p>" +
                        "<p><span style='color: #FFB800;'>吸血: +" + ary.zbxx + "</span></p>" +
                        "<p><span style='color: #FFB800;'>速度: +" + ary.zbsd + "</span></p>" +
                        "<p><hr></p>" +
                        "<p><span>" + ary.zbinfo + "</span></p>";

                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        shadeClose: true,
                        skin: 'yourclass',
                        content: '<div style="width: 200px;height: 300px;padding: 10px;box-sizing: border-box;line-height: 26px;">' + content + '</div>'
                    });
                } else {
                    layer.msg(res.msg);
                }
            });
        });

        $('.ajax-act').on('click', function () {
            var act = $(this).data('act');
            var id = $(this).data('id');

            console.log('act', act, 'id', id);

            var map = {};
            map['act'] = act;
            map['id'] = id;

            $.post("{:url('equipAct')}", map, function (res) {
                if (res.code == undefined) {
                    console.log('res为json字符串', res);
                    res = JSON.parse(res);
                } else {
                    console.log('res为json对象', res);
                }
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                        if (res.data.url != '' && res.data.url != undefined) {
                            window.location.href = res.data.url;
                        } else {
                            location.reload();
                        }
                    });
                } else {
                    layer.msg(res.msg);
                }
            });

        });

        $('.ajax-sell').on('click', function () {
            var act = $(this).data('act');
            var id = $(this).data('id');

            console.log('act', act, 'id', id);

            layer.prompt({title: '输入价格，并确认', formType: 0}, function (price, index) {
                layer.close(index);
                console.log('price', price);

                var map = {};
                map['act'] = act;
                map['id'] = id;
                map['pay'] = price;

                $.post("{:url('equipAct')}", map, function (res) {
                    if (res.code == undefined) {
                        console.log('res为json字符串', res);
                        res = JSON.parse(res);
                    } else {
                        console.log('res为json对象', res);
                    }
                    if (res.code == 1) {
                        layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                            if (res.data.url != '' && res.data.url != undefined) {
                                window.location.href = res.data.url;
                            } else {
                                location.reload();
                            }
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
            });
        });

        $('.ajax-remove').live('click', function (){
            var act = $(this).data('act');
            var id = $(this).data('id');

            console.log('act', act, 'id', id);

            var map = {};
            map['act'] = act;
            map['id'] = id;

            $.post("{:url('equipAct')}", map, function (res) {
                if (res.code == undefined) {
                    console.log('res为json字符串', res);
                    res = JSON.parse(res);
                } else {
                    console.log('res为json对象', res);
                }
                if (res.code == 1) {
                    layer.close();

                    layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                        if (res.data.url != '' && res.data.url != undefined) {
                            window.location.href = res.data.url;
                        } else {
                            location.reload();
                        }
                    });
                } else {
                    layer.msg(res.msg);
                }
            });
        });

        $('.ajax-strong').live('click', function (){
            var id = $(this).data('id');

            window.location.href = '/index/works/refine/id/' + id;
        });

        form.render();
    });
</script>
{/block}